/* -------------------------------------- 

     Cherrypy webapp skeleton frontend

     License: LGPL
     Authors: saaj (mail@saaj.me)

   -------------------------------------- */

/**
 * Note model class
 */
qx.Class.define("webapp.model.NoteEditor", {

  extend : webapp.model.AbstractEditor,

  members : {

    _createFormModel : function()
    {
    	var values = {
        noteId  : null,
        name    : null,
        comment : null
      };

      this._formModel = qx.data.marshal.Json.createModel(values);

      this.fireDataEvent("loaded", values);
    },

    save : function()
    {
      var result = qx.util.Serializer.toNativeObject(this._formModel);
      
    	var rpc = new webapp.network.Rpc(this._serviceName);
      rpc.addListener("completed", function()
      {
        this.fireDataEvent("saved", result);
      }, this);
      
      rpc.call("create", result);
    }

  }

});